limit the number of displayed items by the actual screen height instead of
authorMichael Natterer <mitch@imendio.com>
Thu, 12 Jun 2008 11:17:16 +0000 (11:17 +0000)
committerMichael Natterer <mitch@src.gnome.org>
Thu, 12 Jun 2008 11:17:16 +0000 (11:17 +0000)
2008-06-12  Michael Natterer  <mitch@imendio.com>

* gtk/gtkentrycompletion.c (_gtk_entry_completion_resize_popup):
limit the number of displayed items by the actual screen height
instead of some arbitrary value (Bug #408154, Xan Lopez and
Christian Dywan).

svn path=/trunk/; revision=20359

ChangeLog
gtk/gtkentrycompletion.c

index 5f59525026de10ce70a3348a8538da287e2b48c5..3e271160110447890a21d867a312340e6438e5b2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-06-12  Michael Natterer  <mitch@imendio.com>
+
+       * gtk/gtkentrycompletion.c (_gtk_entry_completion_resize_popup):
+       limit the number of displayed items by the actual screen height
+       instead of some arbitrary value (Bug #408154, Xan Lopez and
+       Christian Dywan).
+
 2008-06-11  Behdad Esfahbod  <behdad@gnome.org>
 
        Bug 503071 – Application direction changes to right to left even if
index 2fc582ecdf397c971f6a8702f782fd4f1ff002ea..d526a5149035ff1875aed0f82865be4f40ae3f0a 100644 (file)
@@ -1383,8 +1383,6 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
 
   matches = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (completion->priv->filter_model), NULL);
 
-  items = MIN (matches, 15);
-
   gtk_tree_view_column_cell_get_size (completion->priv->column, NULL,
                                       NULL, NULL, NULL, &height);
 
@@ -1396,16 +1394,23 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
   
   gtk_widget_realize (completion->priv->tree_view);
 
-  if (items <= 0)
-    gtk_widget_hide (completion->priv->scrolled_window);
-  else
-    gtk_widget_show (completion->priv->scrolled_window);
-
   screen = gtk_widget_get_screen (GTK_WIDGET (completion->priv->entry));
   monitor_num = gdk_screen_get_monitor_at_window (screen, 
                                                  GTK_WIDGET (completion->priv->entry)->window);
   gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
 
+  
+
+  if (y > monitor.height / 2)
+    items = MIN (matches, (monitor.y + y) / height);
+  else
+    items = MIN (matches, (monitor.height - y) / height - 1);
+
+  if (items <= 0)
+    gtk_widget_hide (completion->priv->scrolled_window);
+  else
+    gtk_widget_show (completion->priv->scrolled_window);
+
   if (completion->priv->popup_set_width)
     width = MIN (completion->priv->entry->allocation.width, monitor.width) - 2 * x_border;
   else